add_definitions(-DCOMPILE_FOR_UNIT_TESTS)

macro(vc_add_test name)
   set(scalarTarget "${name}_scalar")
   set(sseTarget "${name}_sse")
   set(lrbTarget "${name}_lrb")

   add_executable(${scalarTarget} ${name}.cpp)
   target_link_libraries(${scalarTarget} Vc)
   add_target_property(${scalarTarget} COMPILE_FLAGS "-DVC_IMPL=Scalar")
   add_test(${scalarTarget} "${CMAKE_CURRENT_BINARY_DIR}/${scalarTarget}")

   if(USE_SSE2 AND NOT SSE_INTRINSICS_BROKEN)
      add_executable(${sseTarget} ${name}.cpp)
      target_link_libraries(${sseTarget} Vc)
      add_target_property(${sseTarget} COMPILE_FLAGS "-DVC_IMPL=SSE")
      add_test(${sseTarget} "${CMAKE_CURRENT_BINARY_DIR}/${sseTarget}")
   endif(USE_SSE2 AND NOT SSE_INTRINSICS_BROKEN)

   if(LARRABEE_FOUND)
      add_executable(${lrbTarget} ${name}.cpp)
      target_link_libraries(${lrbTarget} Vc)
      add_target_property(${lrbTarget} COMPILE_FLAGS "-DVC_IMPL=LRBni")
      add_test(${lrbTarget} "${CMAKE_CURRENT_BINARY_DIR}/${lrbTarget}")
   endif(LARRABEE_FOUND)
endmacro(vc_add_test)

vc_add_test(scalaraccess)
vc_add_test(memory)
vc_add_test(arithmetics)
vc_add_test(expandandmerge)
vc_add_test(load)
vc_add_test(store)
vc_add_test(gather)
vc_add_test(scatter)
vc_add_test(math)
vc_add_test(mask)
vc_add_test(utils)
vc_add_test(deinterleave)

if(USE_SSE2 AND NOT SSE_INTRINSICS_BROKEN)
   add_executable(sse_blend sse_blend.cpp)
   add_test(sse_blend "${CMAKE_CURRENT_BINARY_DIR}/sse_blend")
   target_link_libraries(sse_blend Vc)

   set(target "gather_sse_LOOP")
   add_executable(${target} gather.cpp)
   add_target_property(${target} COMPILE_FLAGS "-DVC_NO_GATHER_TRICKS -DVC_IMPL=SSE")
   target_link_libraries(${target} Vc)
   add_test(${target} "${CMAKE_CURRENT_BINARY_DIR}/${target}")
endif(USE_SSE2 AND NOT SSE_INTRINSICS_BROKEN)
